#!/bin/sh

TIMEOUT=10
IPW3945_ARGS="--quiet"

rm -f /var/run/ipw3945d.pid

if [ "$1" == "--kill" ]; then
	/sbin/killproc /sbin/ipw3945d
	exit 0
fi

while ! test -e /sys/bus/pci/drivers/ipw3945/bind ; do
	i=$((i+1))
	test $i -gt $TIMEOUT && {
		echo "Timeout waiting for ipw3945 driver, skip starting ipw3945d" >&2 ;
		exit 1 ; }
	sleep 1
done
exec /sbin/ipw3945d $IPW3945_ARGS
